package solutions.leetcode.normal

/**
 * @author lizhidong
 * <a href="https://leetcode.cn/problems/count-vowel-strings-in-ranges/">2559. 统计范围内的元音字符串数</a>
 */
private class Solution2559 {
    private fun isY(s: Char) = when (s) {
        'a', 'e', 'i', 'o', 'u' -> true
        else -> false
    }

    fun vowelStrings(words: Array<String>, queries: Array<IntArray>): IntArray {
        val count = IntArray(words.size)
        var now = 0
        for ((ind, item) in words.withIndex()) {
            if (isY(item[0]) && isY(item[item.length - 1])) {
                now++
            }
            count[ind] = now
        }
        return IntArray(queries.size) {
            val ind1 = queries[it][0]
            val ind2 = queries[it][1]
            val a = if(ind1 == 0) 0 else count[ind1 - 1]
            val b = count[ind2]
            b - a
        }
    }
}

fun main() {

}